/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz;

import MatrizDinamica.Matriz;
import datos.PrendaBD;
import datos.UsuarioBD;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import negocio.Prenda;
import negocio.Prendas;

/**
 *
 * @author pablo
 */
public class BuscadorPrenda extends javax.swing.JInternalFrame {

    /**
     * Creates new form BuscadoDardeBaja
     */
    String buscador;
    Prenda prenda = new Prenda();
    Prendas prendas = new Prendas();
    PrendaBD prendadb = new PrendaBD();
    Object[] namecolums = {"IdPrenda", "Nombre", "Fecha", "Numero de Defectos"};
    DefaultTableModel temp = new DefaultTableModel(namecolums, 0);
    boolean estado;
    menu menu;
    private boolean califica;

    public BuscadorPrenda(menu menu) {
        initComponents();

        califica = false;
        bcalificar.setEnabled(false);
        this.menu = menu;
        setTitle("Buscar Prenda");
        this.buscador = "atributo";
        this.estado = false;
        tablaPrendas.setModel(temp);
        this.parametro.setVisible(false);
        this.parametro2.setVisible(false);
        this.bAspGenerales.setVisible(false);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaPrendas = new javax.swing.JTable();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        atributo = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        clasificador = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        aspGenerales = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        cbAtributos = new javax.swing.JComboBox();
        cbClasificador = new javax.swing.JComboBox();
        cbAspGenerales = new javax.swing.JComboBox();
        txtatributo = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        bbuscar = new javax.swing.JButton();
        subClasificador = new javax.swing.JComboBox();
        parametro = new javax.swing.JTextField();
        parametro2 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        bAspGenerales = new javax.swing.JButton();
        cbSubAspGenerales = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        bcalificar = new javax.swing.JButton();
        jSlider1 = new javax.swing.JSlider();
        lcalificacion = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();

        setTitle("Buscar Para Dar De Baja");

        tablaPrendas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tablaPrendas);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Busqueda por Defecto"));

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Atributos");

        atributo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atributoActionPerformed(evt);
            }
        });

        jLabel2.setText("Clasificador");

        clasificador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clasificadorActionPerformed(evt);
            }
        });

        jLabel4.setText("Asp generales");

        aspGenerales.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aspGeneralesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(aspGenerales))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(clasificador, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(atributo, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(atributo)))
                .addGap(7, 7, 7)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(clasificador)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(aspGenerales)
                    .addComponent(jLabel4))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        jLabel3.setText("Buscador por :");

        cbAtributos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-seleccione-", "idvestuario", "nombre", "fech_adquisiscion", "color", "foto", "numlavados", "numusos", "fechalavado", "lavado", "fechalavadoini", "fechalavadofin" }));

        cbClasificador.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-seleccione-", "tipo", "evento", "utilidad", "ubicacion" }));
        cbClasificador.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbClasificadorItemStateChanged(evt);
            }
        });

        cbAspGenerales.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-seleccione-", "rango", "usados", "defectos", "compartidas_individuales" }));
        cbAspGenerales.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbAspGeneralesItemStateChanged(evt);
            }
        });

        txtatributo.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                txtatributoCaretUpdate(evt);
            }
        });

        jLabel5.setText("valor");

        bbuscar.setText("Buscar");
        bbuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bbuscarActionPerformed(evt);
            }
        });

        subClasificador.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        subClasificador.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                subClasificadorItemStateChanged(evt);
            }
        });

        jLabel6.setText("-");

        bAspGenerales.setText("Buscar");
        bAspGenerales.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bAspGeneralesActionPerformed(evt);
            }
        });

        cbSubAspGenerales.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbSubAspGenerales.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbSubAspGeneralesItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(cbAspGenerales, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cbClasificador, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cbAtributos, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(56, 56, 56)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbSubAspGenerales, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(subClasificador, 0, 73, Short.MAX_VALUE)
                    .addComponent(jLabel5))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(txtatributo, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(bbuscar))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(parametro, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 6, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(parametro2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(bAspGenerales)))
                .addGap(0, 122, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                .addGap(32, 32, 32))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbAtributos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtatributo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)
                            .addComponent(bbuscar))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbClasificador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(subClasificador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbAspGenerales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(parametro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(parametro2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)
                            .addComponent(bAspGenerales)
                            .addComponent(cbSubAspGenerales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jButton1.setText("Compartir");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        bcalificar.setText("Calificar");
        bcalificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bcalificarActionPerformed(evt);
            }
        });

        jSlider1.setMaximum(5);
        jSlider1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSlider1StateChanged(evt);
            }
        });

        jButton2.setText("Usar Prenda");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 8, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bcalificar, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(16, 16, 16)
                        .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lcalificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1)
                        .addGap(116, 116, 116))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                    .addComponent(bcalificar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lcalificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void atributoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atributoActionPerformed
        if (estado == false) {
            txtatributo.setEnabled(true);
            this.cbAtributos.setEnabled(true);
            this.atributo.setEnabled(true);
            this.clasificador.setEnabled(false);
            this.aspGenerales.setEnabled(false);
            this.cbClasificador.setEnabled(false);
            this.cbAspGenerales.setEnabled(false);
            this.subClasificador.setEnabled(false);
            this.buscador = "atributo";
            this.cbSubAspGenerales.setEnabled(false);
            this.bbuscar.setEnabled(true);

            estado = true;
        } else {
            this.clasificador.setEnabled(true);
            this.aspGenerales.setEnabled(true);
            txtatributo.setEnabled(false);
            this.cbAtributos.setEnabled(false);

            this.bbuscar.setEnabled(false);

            estado = false;
            DefaultTableModel aux2 = new DefaultTableModel();
            this.tablaPrendas.setModel(aux2);
            this.updateUI();
        }

    }//GEN-LAST:event_atributoActionPerformed

    private void clasificadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clasificadorActionPerformed
        if (estado == false) {
            txtatributo.setEnabled(false);
            this.cbAtributos.setEnabled(false);
            this.atributo.setEnabled(false);
            this.aspGenerales.setEnabled(false);
            this.cbAspGenerales.setEnabled(false);
            this.buscador = "clasificador";
            this.bbuscar.setEnabled(false);
            this.cbSubAspGenerales.setEnabled(false);

            this.clasificador.setEnabled(true);
            this.cbClasificador.setEnabled(true);
            this.subClasificador.setEnabled(true);

            estado = true;
        } else {
            estado = false;
            this.atributo.setEnabled(true);
            this.aspGenerales.setEnabled(true);

            this.cbClasificador.setEnabled(false);
            this.subClasificador.setEnabled(false);
            DefaultTableModel aux2 = new DefaultTableModel();
            this.tablaPrendas.setModel(aux2);
            this.updateUI();

        }

    }//GEN-LAST:event_clasificadorActionPerformed

    private void aspGeneralesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aspGeneralesActionPerformed
        if (estado == false) {
            txtatributo.setEnabled(false);
            this.cbAtributos.setEnabled(false);
            this.atributo.setEnabled(false);
            this.bbuscar.setEnabled(false);
            this.buscador = "otro";
            this.clasificador.setEnabled(false);
            this.cbClasificador.setEnabled(false);
            this.subClasificador.setEnabled(false);
            this.bbuscar.setEnabled(false);
            this.cbSubAspGenerales.setEnabled(false);
            this.aspGenerales.setEnabled(true);
            this.cbAspGenerales.setEnabled(true);

            estado = true;
        } else {
            estado = false;
            this.atributo.setEnabled(true);
            this.clasificador.setEnabled(true);
            this.cbAspGenerales.setEnabled(false);
            this.bAspGenerales.setEnabled(false);
            this.cbSubAspGenerales.setEnabled(false);
            DefaultTableModel aux2 = new DefaultTableModel();
            this.tablaPrendas.setModel(aux2);
            this.updateUI();

        }

// TODO add your handling code here:
    }//GEN-LAST:event_aspGeneralesActionPerformed

    private void txtatributoCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtatributoCaretUpdate
    }//GEN-LAST:event_txtatributoCaretUpdate
    public void buscarPrenda() {

        if (txtatributo.getText().length() > 0) {
            DefaultTableModel aux = new DefaultTableModel();
            try {
                ResultSet rs = this.prendadb.buscadorPrenda(buscador, this.cbAtributos.getSelectedItem().toString(), txtatributo.getText(), "", "345");
                //Obteniendo la informacion de las columnas que estan siendo consultadas
                ResultSetMetaData rsMd = rs.getMetaData();
                //La cantidad de columnas que tiene la consulta
                int cantidadColumnas = rsMd.getColumnCount();
                //Establecer como cabezeras el nombre de las colimnas
                for (int i = 1; i <= cantidadColumnas; i++) {
                    aux.addColumn(rsMd.getColumnLabel(i));
                }
                //Creando las filas para el JTable
                while (rs.next()) {

                    Object[] fila = new Object[cantidadColumnas];
                    for (int i = 0; i < cantidadColumnas; i++) {
                        fila[i] = rs.getObject(i + 1);
                    }
                    aux.addRow(fila);
                }
                this.tablaPrendas.setModel(aux);
                TableColumnModel modelo_columna = tablaPrendas.getColumnModel();
                modelo_columna.setColumnMargin(80);
                this.tablaPrendas.updateUI();

// TODO add your handling code here:
            } catch (SQLException ex) {
                Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    private void bbuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bbuscarActionPerformed

        buscarPrenda();
// TODO add your handling code here:
    }//GEN-LAST:event_bbuscarActionPerformed

    private void subClasificadorItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_subClasificadorItemStateChanged
        if (this.cbClasificador.getSelectedIndex() != -1 && this.subClasificador.getSelectedIndex() != -1) {
            if (!this.cbClasificador.getSelectedItem().toString().equals("-seleccione-") && !this.subClasificador.getSelectedItem().toString().equals("-seleccione-")) {
                buscarPrendaClasificador();
            }
        }
    }//GEN-LAST:event_subClasificadorItemStateChanged

    private void cbClasificadorItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbClasificadorItemStateChanged

        if (cbClasificador.getSelectedItem().toString().equals("tipo")) {
            subClasificador.removeAllItems();
            subClasificador.addItem("-seleccione-");
            subClasificador.addItem("formal");
            subClasificador.addItem("semiformal");
            subClasificador.addItem("informal");
            subClasificador.updateUI();

        }
        if (cbClasificador.getSelectedItem().toString().equals("evento")) {
            subClasificador.removeAllItems();
            subClasificador.addItem("-seleccione-");
            subClasificador.addItem("fiestas");
            subClasificador.addItem("diario");
            subClasificador.addItem("reuniones");
            subClasificador.addItem("deporte");
            subClasificador.updateUI();

        }
        if (cbClasificador.getSelectedItem().toString().equals("utilidad")) {
            subClasificador.removeAllItems();
            subClasificador.addItem("-seleccione-");
            subClasificador.addItem("basica");
            subClasificador.addItem("complementaria");
            subClasificador.updateUI();
        }
        if (cbClasificador.getSelectedItem().toString().equals("ubicacion")) {
            subClasificador.removeAllItems();
            subClasificador.addItem("-seleccione-");
            subClasificador.addItem("arriba");
            subClasificador.addItem("abajo");
            subClasificador.addItem("unica");
            subClasificador.updateUI();

        }

// TODO add your handling code here:
    }//GEN-LAST:event_cbClasificadorItemStateChanged

    private void cbAspGeneralesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbAspGeneralesItemStateChanged

        if (this.cbAspGenerales.getSelectedItem().toString().equals("rango")) {
            this.parametro.setVisible(true);
            this.parametro2.setVisible(true);
            this.bAspGenerales.setVisible(true);
            this.cbSubAspGenerales.setVisible(false);

        }
        if (this.cbAspGenerales.getSelectedItem().toString().equals("usados")) {
            this.parametro.setVisible(false);
            this.parametro2.setVisible(false);
            this.bAspGenerales.setVisible(false);
            this.cbSubAspGenerales.setVisible(false);
            this.buscarPrendaUsos();

        }
        if (this.cbAspGenerales.getSelectedItem().toString().equals("defectos")) {
            this.cbSubAspGenerales.setVisible(true);
            this.cbSubAspGenerales.setEnabled(true);

            this.parametro.setVisible(false);
            this.parametro2.setVisible(false);
            this.bAspGenerales.setVisible(false);
            this.cbSubAspGenerales.removeAllItems();
            this.cbSubAspGenerales.addItem("-seleccione-");
            this.cbSubAspGenerales.addItem("con defectos");
            this.cbSubAspGenerales.addItem("sin defectos");
            this.cbSubAspGenerales.updateUI();

        }
        if (this.cbAspGenerales.getSelectedItem().toString().equals("compartidas_individuales")) {
            this.parametro.setVisible(false);
            this.parametro2.setVisible(false);
            this.bAspGenerales.setVisible(false);
            this.cbSubAspGenerales.setEnabled(true);
            this.cbSubAspGenerales.removeAllItems();
            this.cbSubAspGenerales.addItem("-seleccione-");
            this.cbSubAspGenerales.addItem("compartidas");
            this.cbSubAspGenerales.addItem("individual");
            this.cbSubAspGenerales.updateUI();

        }

// TODO add your handling code here:
    }//GEN-LAST:event_cbAspGeneralesItemStateChanged

    private void bAspGeneralesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAspGeneralesActionPerformed
        if (parametro.getText().length() > 0 && parametro2.getText().length() > 0) {
            this.buscarPrendaRango(parametro.getText(), parametro2.getText());
        }

// TODO add your handling code here:
    }//GEN-LAST:event_bAspGeneralesActionPerformed

    private void cbSubAspGeneralesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbSubAspGeneralesItemStateChanged
        if (cbSubAspGenerales.getSelectedIndex() != -1) {
            if (this.cbSubAspGenerales.getSelectedItem().toString().equals("con defectos")) {
                this.buscarPrendaDefectos(1);

            }
            if (this.cbSubAspGenerales.getSelectedItem().toString().equals("sin defectos")) {
                this.buscarPrendaDefectos(2);
            }
            if (this.cbSubAspGenerales.getSelectedItem().toString().equals("compartidas")) {
                this.buscarPrendaCompartida();
            }
            if (this.cbSubAspGenerales.getSelectedItem().toString().equals("individual")) {
                this.buscarPrendaIndividual();
            }
        }
// TODO add your handling code here:
    }//GEN-LAST:event_cbSubAspGeneralesItemStateChanged

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        if (tablaPrendas.getSelectedRow() != -1) {
            CompartirVestuario cv = new CompartirVestuario(tablaPrendas.getValueAt(tablaPrendas.getSelectedRow(), 0).toString(), this.menu);

            menu.escritorio.add(cv);
            menu.centerJIF(cv);

        }

// TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void bcalificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bcalificarActionPerformed

        if (tablaPrendas.getSelectedRow() != -1 && califica) {
            califica = false;
            bcalificar.setEnabled(false);
            try {
                if (this.prendadb.calificar(this.menu.usercedula, Integer.parseInt(tablaPrendas.getValueAt(tablaPrendas.getSelectedRow(), 0).toString()), jSlider1.getValue())) {
                    JOptionPane.showMessageDialog(null, "Prenda calificada");
                } else {
                    JOptionPane.showMessageDialog(null, "Prenda calificada");
                }
            } catch (SQLException ex) {
                Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

// TODO add your handling code here:
    }//GEN-LAST:event_bcalificarActionPerformed

    private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSlider1StateChanged
        if (tablaPrendas.getSelectedRow() != -1) {
            califica = true;
            bcalificar.setEnabled(true);

            lcalificacion.setText(Integer.toString(jSlider1.getValue()));
        }       // TODO add your handling code here:
    }//GEN-LAST:event_jSlider1StateChanged

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        if (tablaPrendas.getSelectedRow() != -1) {
            menu.estado = 4;
            intefarUso Intuso = new intefarUso(menu.usernombre, menu.usercedula, tablaPrendas.getValueAt(tablaPrendas.getSelectedRow(), 0).toString());
            menu.escritorio.add(Intuso);
            menu.centerJIF(Intuso);
        } else {
            JOptionPane.showMessageDialog(null, "Seleccione una prenda");
        }
// TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JRadioButton aspGenerales;
    private javax.swing.JRadioButton atributo;
    private javax.swing.JButton bAspGenerales;
    private javax.swing.JButton bbuscar;
    private javax.swing.JButton bcalificar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cbAspGenerales;
    private javax.swing.JComboBox cbAtributos;
    private javax.swing.JComboBox cbClasificador;
    private javax.swing.JComboBox cbSubAspGenerales;
    private javax.swing.JRadioButton clasificador;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSlider jSlider1;
    private javax.swing.JLabel lcalificacion;
    private javax.swing.JTextField parametro;
    private javax.swing.JTextField parametro2;
    private javax.swing.JComboBox subClasificador;
    private javax.swing.JTable tablaPrendas;
    private javax.swing.JTextField txtatributo;
    // End of variables declaration//GEN-END:variables

    private void buscarPrendaClasificador() {

        DefaultTableModel aux = new DefaultTableModel();
        try {
            ResultSet rs = this.prendadb.buscadorPrenda(buscador, this.cbClasificador.getSelectedItem().toString(), this.subClasificador.getSelectedItem().toString(), "", "345");
            //Obteniendo la informacion de las columnas que estan siendo consultadas
            ResultSetMetaData rsMd = rs.getMetaData();
            //La cantidad de columnas que tiene la consulta
            int cantidadColumnas = rsMd.getColumnCount();
            //Establecer como cabezeras el nombre de las colimnas
            for (int i = 1; i <= cantidadColumnas; i++) {
                aux.addColumn(rsMd.getColumnLabel(i));
            }
            //Creando las filas para el JTable
            while (rs.next()) {

                Object[] fila = new Object[cantidadColumnas];
                for (int i = 0; i < cantidadColumnas; i++) {
                    fila[i] = rs.getObject(i + 1);
                }
                aux.addRow(fila);
            }
            this.tablaPrendas.setModel(aux);
            this.tablaPrendas.updateUI();

// TODO add your handling code here:
        } catch (SQLException ex) {
            Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void buscarPrendaRango(String parametro, String parametro2) {

        DefaultTableModel aux = new DefaultTableModel();
        try {
            ResultSet rs = this.prendadb.buscadorPrendaRango(buscador, this.cbAspGenerales.getSelectedItem().toString(), parametro, parametro2, "345");
            //Obteniendo la informacion de las columnas que estan siendo consultadas
            ResultSetMetaData rsMd = rs.getMetaData();
            //La cantidad de columnas que tiene la consulta
            int cantidadColumnas = rsMd.getColumnCount();
            //Establecer como cabezeras el nombre de las colimnas
            for (int i = 1; i <= cantidadColumnas; i++) {
                aux.addColumn(rsMd.getColumnLabel(i));
            }
            //Creando las filas para el JTable
            while (rs.next()) {

                Object[] fila = new Object[cantidadColumnas];
                for (int i = 0; i < cantidadColumnas; i++) {
                    fila[i] = rs.getObject(i + 1);
                }
                aux.addRow(fila);
            }
            this.tablaPrendas.setModel(aux);
            this.tablaPrendas.updateUI();

// TODO add your handling code here:
        } catch (SQLException ex) {
            Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void buscarPrendaUsos() {

        DefaultTableModel aux = new DefaultTableModel();
        try {
            ResultSet rs = this.prendadb.buscadorPrendaUsos(buscador, this.cbAspGenerales.getSelectedItem().toString(), "", "", "345");
            //Obteniendo la informacion de las columnas que estan siendo consultadas
            ResultSetMetaData rsMd = rs.getMetaData();
            //La cantidad de columnas que tiene la consulta
            int cantidadColumnas = rsMd.getColumnCount();
            //Establecer como cabezeras el nombre de las colimnas
            for (int i = 1; i <= cantidadColumnas; i++) {
                aux.addColumn(rsMd.getColumnLabel(i));
            }
            //Creando las filas para el JTable
            while (rs.next()) {

                Object[] fila = new Object[cantidadColumnas];
                for (int i = 0; i < cantidadColumnas; i++) {
                    fila[i] = rs.getObject(i + 1);
                }
                aux.addRow(fila);
            }
            this.tablaPrendas.setModel(aux);
            this.tablaPrendas.updateUI();

// TODO add your handling code here:
        } catch (SQLException ex) {
            Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void buscarPrendaDefectos(int opc) {

        DefaultTableModel aux = new DefaultTableModel();
        try {
            ResultSet rs = null;
            if (opc == 1) {
                rs = this.prendadb.buscadorPrendaDefectos1(buscador, this.cbAspGenerales.getSelectedItem().toString(), this.cbSubAspGenerales.getSelectedItem().toString(), "con defectos", "345");
            }
            if (opc == 2) {
                rs = this.prendadb.buscadorPrendaDefectos2(buscador, this.cbAspGenerales.getSelectedItem().toString(), this.cbSubAspGenerales.getSelectedItem().toString(), "", "345");
            }//Obteniendo la informacion de las columnas que estan siendo consultadas
            ResultSetMetaData rsMd = rs.getMetaData();
            //La cantidad de columnas que tiene la consulta
            int cantidadColumnas = rsMd.getColumnCount();
            //Establecer como cabezeras el nombre de las colimnas
            for (int i = 1; i <= cantidadColumnas; i++) {
                aux.addColumn(rsMd.getColumnLabel(i));
            }
            //Creando las filas para el JTable
            while (rs.next()) {

                Object[] fila = new Object[cantidadColumnas];
                for (int i = 0; i < cantidadColumnas; i++) {
                    fila[i] = rs.getObject(i + 1);
                }
                aux.addRow(fila);
            }
            this.tablaPrendas.setModel(aux);
            this.tablaPrendas.updateUI();

// TODO add your handling code here:
        } catch (SQLException ex) {
            Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void buscarPrendaCompartida() {
        DefaultTableModel aux = new DefaultTableModel();
        try {
            ResultSet rs = null;

            rs = this.prendadb.buscadorPrendaIndividual(buscador, this.cbAspGenerales.getSelectedItem().toString(), this.cbSubAspGenerales.getSelectedItem().toString(), "", "345");

            ResultSetMetaData rsMd = rs.getMetaData();
            //La cantidad de columnas que tiene la consulta
            int cantidadColumnas = rsMd.getColumnCount();
            //Establecer como cabezeras el nombre de las colimnas
            for (int i = 1; i <= cantidadColumnas; i++) {
                aux.addColumn(rsMd.getColumnLabel(i));
            }
            //Creando las filas para el JTable
            while (rs.next()) {

                Object[] fila = new Object[cantidadColumnas];
                for (int i = 0; i < cantidadColumnas; i++) {
                    fila[i] = rs.getObject(i + 1);
                }
                aux.addRow(fila);
            }
            this.tablaPrendas.setModel(aux);
            this.tablaPrendas.updateUI();

// TODO add your handling code here:
        } catch (SQLException ex) {
            Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void buscarPrendaIndividual() {
        DefaultTableModel aux = new DefaultTableModel();
        try {
            ResultSet rs = null;
            rs = this.prendadb.buscadorPrendaCompartida(buscador, this.cbAspGenerales.getSelectedItem().toString(), this.cbSubAspGenerales.getSelectedItem().toString(), "", "345");

            ResultSetMetaData rsMd = rs.getMetaData();
            int cantidadColumnas = rsMd.getColumnCount();
            for (int i = 1; i <= cantidadColumnas; i++) {
                aux.addColumn(rsMd.getColumnLabel(i));

            }
            while (rs.next()) {

                Object[] fila = new Object[cantidadColumnas];
                for (int i = 0; i < cantidadColumnas; i++) {
                    fila[i] = rs.getObject(i + 1);
                }
                aux.addRow(fila);
            }
            this.tablaPrendas.setModel(aux);
            this.tablaPrendas.updateUI();

// TODO add your handling code here:
        } catch (SQLException ex) {
            Logger.getLogger(BuscadorPrenda.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
